package com.insyte.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.widget.ImageView;

import com.insyte.R;
import com.insyte.config.Constants;
import com.insyte.config.InsyteApp;
import com.insyte.utils.MultipleScreen;


public class SplashActivity extends Activity {
    private ImageView imgLogo;
    float fImageLogoW = 362;
    float fImageLogoH = 149;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        Constants.fScale = MultipleScreen.getScale(this);
        initUI();
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (InsyteApp.getInstance().getUser().getToken().equalsIgnoreCase(""))
                    startActivity(new Intent(SplashActivity.this, WelcomeActivity.class));//WelcomeActivity
                else {
                    startActivity(new Intent(SplashActivity.this, TabMainActivity.class));
                    Log.d("userToken",InsyteApp.getInstance().getUser().getToken());
                    Log.d("userId",InsyteApp.getInstance().getUser().getId());
                }
                finish();
            }
        }, 2500);
    }

    private void initUI() {
        imgLogo = (ImageView) findViewById(R.id.img_logo_splash);
        imgLogo.getLayoutParams().width = (int) (fImageLogoW * Constants.fScale);
        imgLogo.getLayoutParams().height = (int) (fImageLogoH * Constants.fScale);
    }

}
